/*==================*\
# Cubes - the 1x1x1  #
# Direct connection  #
\*==================*/

// Map a LED# to actual pin#
const int Pp = 9 ; // The plus side
const int Pn = 8 ; // The minus side
//(The minus side could just go to ground instead of using a pin)

//(Arduino note: "const" means the variables never change and may thus not use memory)

void setup() {
  // Set pins for simple output
  pinMode(Pp,OUTPUT); // pins start in LOW
  pinMode(Pn,OUTPUT); 
  pinMode(13,OUTPUT); // Debug - pin 13 "echo"s the real LED
}

// Here patterns are generated directly in the loop with code
// The loop only runs once for every complete sequence
// delay() is used as there is no other activity.

void loop() {

  // pattern 1 - turn on each LED singly
  // for one LED .... :-)
  digitalWrite(Pp,HIGH); digitalWrite(13,HIGH);
  delay(500);
  digitalWrite(Pp,LOW); digitalWrite(13,LOW);
  delay(250);

  delay(555) ; // interpattern delay - as it is not so obvious with one LED
  
  // Pattern 2 - turn "all" LEDs On/Off together, 3 times
  // a repeat of pattern 1, but visually we do it faster
  for ( int b=0; b<3; b++) {
    digitalWrite(Pp,HIGH); digitalWrite(13,HIGH);
    delay(250);
    digitalWrite(Pp,LOW); digitalWrite(13,LOW);
    delay(150);
  }

  delay(555) ; // interpattern delay - as it is not so obvious with one LED

  // Pattern 3 - Pan across axis
  // makes no sense, so here we repeat of pattern 1, but do it faster&faster
  for ( int b=0; b<10; b++ ) {
    for ( int n=0; n<3 ; n++) {
      digitalWrite(Pp,HIGH); digitalWrite(13,HIGH);
      delay(110-b*10);
      digitalWrite(Pp,LOW); digitalWrite(13,LOW);
      delay(55-b*5);
    }
  }
  digitalWrite(Pp,LOW) ; digitalWrite(13,LOW);
  
  delay(555) ; // interpattern delay - as it is not so obvious with one LED
  
}
